package cn.lefull;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Delivery;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @description:
 * @auther: qijiang
 * @date: 2018/12/21 15:19
 */

@Component
@RabbitListener(queues = "hello")
public class HelloReceiver {

    @RabbitHandler
    public void process(String hello) {
        System.out.println(111111);
        System.out.println(hello);
//        try {
//            channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
    }

//    @RabbitHandler
//    public void process(Message message, Channel channel){
//        String messageRec = new String(message.getBody());
//        System.out.println("接收到的字符串消息是 => " + messageRec);
//        try {
//            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//    }
}
